Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: Bind with members when type has cast to interface #17438

Merged
merged 1 commit into from
Aug 27, 2019

Conversation

smitpatel
Copy link
Contributor

@smitpatel smitpatel commented Aug 27, 2019

Resolves #17276
Resolves #17099
Resolves #16759

Description

EF Core doesn't support mapping to interfaces directly. However, people frequently work with interfaces and we have provided guidance many times in the past on patterns that involve casting or using generic type constraints to work with interfaces. These patterns are not working in the new query pipeline like they were in the old, so we want to take a change for 3.0 that will allow these patterns to work again.

Example:

public static List<T> List<T>(this IQueryable<T> query) where T : IRemovable
    => query.Where(x => !x.IsRemoved).ToList();

Customer Impact

We expect that continuing to work with interfaces will be a common customer requirement for EF Core 3.0. We have not been able to come up with other workarounds that allow this.

Regression?

Yes, from 2.2.

Risk

The risk here is low because the code now handles interfaces types where it previously it would result in an exception. These changes are localized to specific places in the code and should have no impact on the handling of non-interface types.

@smitpatel smitpatel changed the base branch from master to release/3.0 August 27, 2019 01:21
Copy link
Member

@ajcvickers ajcvickers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@smitpatel Approved by me, but wait for ask mode approval before merging.

@ajcvickers ajcvickers added this to the 3.0.0 milestone Aug 27, 2019
@ajcvickers
Copy link
Member

@smitpatel This is approved by Tactics; you may merge.

@smitpatel smitpatel merged commit 010b45d into release/3.0 Aug 27, 2019
@ghost ghost deleted the smit/interfaces branch August 27, 2019 18:28
@ajcvickers ajcvickers removed this from the 3.0.0 milestone Aug 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants